<template>
    <div>
        <h3>登录界面</h3>

        <table class="table">
           <tbody>
                <tr>
                    <td>账号</td>
                    <td>
                        <input type="text" v-model="data.lname">
                    </td>
                </tr>
                <tr>
                    <td>密码</td>
                    <td>
                        <input type="password" v-model="data.lpwd">
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <input type="button" value="登录" @click="deng">
                    </td>
                </tr>
           </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">

import axios from 'axios';
import { ref } from 'vue';
import { useRouter } from 'vue-router';

const router=useRouter()

const data=ref({
    lname:"",
    lpwd:""
})

const deng=()=>{
    axios.get("https://localhost:7228/api/HouseType/Login",{params:data.value}).then(res=>{
        if(res.data==-1)
        {
            alert("用户名不存在");
        }
        else if(res.data==-2)
        {
            alert("密码错误");
        }
        else
        {
            alert("登录成功");
            router.push({path:"/add"})
        }
    })
}

</script>

<style scoped>

</style>